package bg.btanev.eightyfour.client.composite;

import com.google.gwt.event.logical.shared.HasCloseHandlers;
import com.google.gwt.event.logical.shared.HasOpenHandlers;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 *
 * @author B.Tanev
 *
 */
public class ExpandableListElementComposite extends Composite {

	private final DisclosurePanel disclosurePanel;
	private final VerticalPanel dataPanel;
	private final HorizontalPanel headerPanel;

	public ExpandableListElementComposite() {
		disclosurePanel = new DisclosurePanel();
		initWidget(disclosurePanel);

		disclosurePanel.setOpen(true);
		disclosurePanel.setAnimationEnabled(true);
		disclosurePanel.setWidth("100%");
		disclosurePanel.setOpen(false);

		headerPanel = new HorizontalPanel();
		headerPanel.setSpacing(2);
		disclosurePanel.setHeader(headerPanel);
		headerPanel.setWidth("100%");

		dataPanel = new VerticalPanel();
		dataPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
		disclosurePanel.setContent(dataPanel);
		dataPanel.setWidth("100%");
	}

	protected HasWidgets getDataPanel() {
		return dataPanel;
	}

	protected HorizontalPanel getHeaderPanel() {
		return headerPanel;
	}

	protected HasOpenHandlers<DisclosurePanel> getOpenHandlers() {
		return disclosurePanel;
	}

	protected HasCloseHandlers<DisclosurePanel> getCloseHandlers() {
		return disclosurePanel;
	}
}
